import {createApp} from 'vue'
import website from './config/website'
import axios from './axios';
import router from './router/';
import store from './store';
import i18n from './lang/';
import {language, messages} from './lang/';
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import Avue from '@smallwei/avue';
import '@smallwei/avue/lib/index.css';
import crudCommon from '@/mixins/crud.js'
import {getScreen} from './utils/util'
import './permission';
import error from './error';
import avueUeditor from 'avue-plugin-ueditor'
import basicBlock from 'components/basic-block/main.vue'
import basicContainer from 'components/basic-container/main.vue'
import App from './App.vue'
import 'animate.css'
import dayjs from 'dayjs'
import 'styles/common.scss';
import VueClipboard from 'vue3-clipboard';
import highlight from './components/highlight/main.vue';
import codeEditor from './components/code-editor/main.vue';

// ============ ↓ 业务组件 ↓ ============
import functionStruct from './views/iot/component/functionStruct.vue';
import functionStructFull from './views/iot/component/functionStructFull.vue';
import functionEnum from './views/iot/component/functionEnum.vue';
import mqttTable from './views/iot/component/mqttTable.vue';
import simulatorProperty from './views/iot/component/simulatorProperty.vue';
import simulatorEvent from './views/iot/component/simulatorEvent.vue';
import simulatorCommand from './views/iot/component/simulatorCommand.vue';
import categoryInfo from './views/iot/category/categoryInfo.vue';
import categoryFunction from './views/iot/category/categoryFunction.vue';
import categoryDraft from './views/iot/category/categoryDraft.vue';
import productInfo from './views/iot/product/productInfo.vue';
import productTopic from './views/iot/product/productTopic.vue';
import productFunction from './views/iot/product/productFunction.vue';
import productScript from './views/iot/product/productScript.vue';
import productDevice from './views/iot/product/productDevice.vue';
import productOss from './views/iot/product/productOss.vue';
import productSubset from './views/iot/product/productSubset.vue';
import productRelay from './views/iot/product/productRelay.vue';
import deviceInfo from './views/iot/device/deviceInfo.vue';
import deviceTopic from './views/iot/device/deviceTopic.vue';
import deviceFunction from './views/iot/device/deviceFunction.vue';
import deviceShadow from './views/iot/device/deviceShadow.vue';
import deviceGroup from './views/iot/device/deviceGroup.vue';
import deviceSubset from './views/iot/device/deviceSubset.vue';
import deviceTask from './views/iot/device/deviceTask.vue';
import deviceLog from './views/iot/device/deviceLog.vue';
import deviceMqtt from './views/iot/device/deviceMqtt.vue';
import groupInfo from './views/iot/group/groupInfo.vue';
import groupDevice from './views/iot/group/groupDevice.vue';
import edgeFlows from './views/iot/edge/flows.vue';
// ============ ↑ 业务组件 ↑ ============

window.$crudCommon = crudCommon
window.axios = axios;
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.component('basicContainer', basicContainer)
app.component('basicBlock', basicBlock)
app.component('highlight', highlight)
app.component('codeEditor', codeEditor)

// ============ ↓ 业务组件 ↓ ============
app.component('functionStruct', functionStruct);
app.component('functionStructFull', functionStructFull);
app.component('functionEnum', functionEnum);
app.component('mqttTable', mqttTable);
app.component('simulatorProperty', simulatorProperty);
app.component('simulatorEvent', simulatorEvent);
app.component('simulatorCommand', simulatorCommand);
app.component('categoryInfo', categoryInfo);
app.component('categoryFunction', categoryFunction);
app.component('categoryDraft', categoryDraft);
app.component('productInfo', productInfo);
app.component('productTopic', productTopic);
app.component('productFunction', productFunction);
app.component('productScript', productScript);
app.component('productDevice', productDevice);
app.component('productRelay', productRelay);
app.component('productOss', productOss);
app.component('productSubset', productSubset);
app.component('deviceInfo', deviceInfo);
app.component('deviceTopic', deviceTopic);
app.component('deviceFunction', deviceFunction);
app.component('deviceShadow', deviceShadow);
app.component('deviceGroup', deviceGroup);
app.component('deviceSubset', deviceSubset);
app.component('deviceTask', deviceTask);
app.component('deviceLog', deviceLog);
app.component('deviceMqtt', deviceMqtt);
app.component('groupInfo', groupInfo);
app.component('groupDevice', groupDevice);
app.component('edgeFlows', edgeFlows);
// ============ ↑ 业务组件 ↑ ============

app.config.globalProperties.$dayjs = dayjs
app.config.globalProperties.website = website
app.config.globalProperties.getScreen = getScreen
app.use(error);
app.use(i18n)
app.use(store)
app.use(router)
app.use(ElementPlus, {
  locale: messages[language]
})
app.use(Avue, {
  axios,
  calcHeight: 10,
  locale: messages[language]
})
app.use(VueClipboard, {
  autoSetContainer: true,
  appendToBody: true, // 这可以帮助解决一些更复杂的使用场景下的问题
})

app.use(avueUeditor, {axios})
app.mount('#app')
